// pages/myCode/myCode.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    app.showShareMenus();
   // getCodes(this);
    this.setData({
      imageUrl: app.globalData.imageUrl
    })
  this.setData({
    userids:wx.getStorageSync('userid')
  })
  },
  clickImage:function(e){
    wx.previewImage({
      urls: [e.target.id],
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    return {
      title: '美甲美睫半永久化妆造型',
      path: '/pages/homepage/homepage?id=' + wx.getStorageSync("userid"),
    }
  },
})

function getCodes(that){
/*  wx.request({
    url: app.globalData.allUrl + "/utilAction/getAccessToken",
    data: {

    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
     var userid=wx.getStorageSync('userid')
     var sss = '{ "scene": '+userid+' }';
     console.log(sss);
      wx.request({
        url: "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+res.data,
        data: sss,
        method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
        // header: {}, // 设置请求的 header
        success: function (res) {
          console.log(res);
          wx.request({
            url: app.globalData.allUrl + "/utilAction/getminiqrQr",
            data: {
              qrcode: res.data
            },
            method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
            header: {
              'content-type':
              'application/x-www-form-urlencoded'}, // 设置请求的 header
            success: function (res) {
              console.log(res);
              that.setData({
                
              })

            }
          })
        }
      })
     
    }
  })*/
  wx.request({
    url: app.globalData.allUrl + "/utilAction/getminiqrQr",
    data: {
      userId: wx.getStorageSync('userid')
    },
    method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    header: {
      'content-type':
      'application/x-www-form-urlencoded'
    }, // 设置请求的 header
    success: function (res) {
      console.log(res);
      that.setData({

      })

    }
  })
}